﻿using System;
using Bricks.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace Bricks.EnterpriseLibrary.Logging
{
    
    /// <summary>
    /// 
    /// </summary>
    public class LogWriterFacade : LoggerFacadeBase<LogWriter>, ILogWriterFacade
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logWriter"></param>
        public LogWriterFacade(LogWriter logWriter) :
            base(() => logWriter)
        {
            if (logWriter == null)
            {
                throw new ArgumentNullException("logWriter");
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        public override void Debug(object message)
        {
            Execute(logWriter => logWriter.Write(message, ConfigKeys.Debug));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        public override void Error(object message)
        {
            Execute(logWriter => logWriter.Write(message, ConfigKeys.Error));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        public override void Fatal(object message)
        {
            Execute(logWriter => logWriter.Write(message, ConfigKeys.Fatal));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        public override void Info(object message)
        {
            Execute(logWriter => logWriter.Write(message, ConfigKeys.Info));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message"></param>
        public override void Warn(object message)
        {
            Execute(logWriter => logWriter.Write(message, ConfigKeys.Warn));
        }
    }
}
